package com.zmytest.many2one;

import com.zmytest.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * Created on 2018/12/24.
 *
 * @author zhangmingyu
 */
@EqualsAndHashCode(callSuper = false)
@Data
@Entity
public class Member extends BaseModel<Integer> {

    private String name;

// 这种方式，保存的时候，必须要给groupId赋值，否则保存不上关联关系。而且保存的返回值中不存在Group信息，需要再次查询出来的Member才能带出Group信息
//    private Integer groupId;
//    @ManyToOne
//    @JoinColumn(name = "groupId",insertable = false,updatable = false)
//    private Group group;

    @ManyToOne
    @JoinColumn(name = "groupId")
    private Group group;

}
